<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
<script type="text/javascript" src="../js/jquery.bootstrap.min.js" ></script>
<link rel="stylesheet" href="../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
<script type="text/javascript" src="../js/bootstrap-3.3.7-dist/js/bootstrap.min.js" ></script>
<script type="text/javascript" src="../js/bank.js"></script>
<script type="text/javascript" src="../js/plugins/jquery.form.js"></script>
<script type="text/javascript" src="../js/plugins/jquery.twbsPagination.min.js"></script>
<script type="text/javascript" src="../js//WdatePicker.js" ></script>
<link type="text/css" rel="stylesheet" href="../css/account.css" />

<html>

	<head>
		<meta charset="UTF-8">
		<title>p2p互联网金融平台后台管理</title>
		<script type="text/javascript">
		function toPage(page) {
            $("#myform").attr("action","../p2p/selectDictionaryItem?currPage="+page+"&title"+${"[name='title']"}+"&dic"+${"[name='dic']"});
            $("#myform").submit();
        }
		
		function Delete(itemId) {
			 if(confirm("你确定要删除吗?")){
				 $("#myform").attr("action","../p2p/deleteDictionaryItem?itemId="+itemId);
		         $("#myform").submit();
	            }
        }
		
		$(function() {
            //拿到当前页
            var currPage = ${page.currPage};
            //拿到最后一页
            var totalPages = ${page.totalPages};

            if (currPage <= 1) {
                $("#prev").attr("disabled","disabled");
            }

            if (currPage >= totalPages) {
            	$("#next").attr("disabled","disabled");
            }
        });
		</script>
		<script type="text/javascript">
			$(function(){
				$("#btn_add").click(function(){
					$("#myModalLabel").text("增加数据字典明细");
			 		$("#myModal").modal();
			 	});
				
				$("#btn_submit").click(function(){
					/* alert("666"); */
					 $("#myForm2").attr("action","../p2p/insertDictionaryItem");
			         $("#myForm2").submit();
				});
			});
			 
		</script>
	</head>

<body>
	<c:if test="${param.sp == 'deleteOk' }" >
        <script>
            alert("删除成功");
        </script>
    </c:if>
    <c:if test="${param.sp == 'deleteNo' }" >
        <script>
            alert("删除失败");
        </script>
    </c:if>
    <c:if test="${param.sp == 'insertOk' }" >
        <script>
            alert("添加成功");
        </script>
    </c:if>
    <c:if test="${param.sp == 'insertNo' }" >
        <script>
            alert("添加失败");
        </script>
    </c:if>
	<div class="container">
		<div class="navbar cm-navbar">
			<img class="logo" alt="Brand" src="/images/logo.png"> <span
				class="pageTitle">&nbsp;</span>
			<ul class="nav navbar-nav navbar-right cm-navbar-nav">
				<li>
					<c:if test="${sessionScope.user.userName!=null}">
						<p class="navbar-text text-info">${sessionScope.user.userName}</p>
					</c:if>
				</li>
				<li><a href="">安全退出</a></li>
				<li><a href="">个人设置</a></li>
			</ul>
		</div>
		<div class="row">
			<div class="col-sm-3">
				<ul id="menu" class="list-group">
					<li class="list-group-item"><a href="#" data-toggle="collapse"
						data-target="#permissionmanage_detail"><span>安全管理</span></a>
						<ul class="in" id="permissionmanage_detail">
							<li class="systemDictionary"><a href="../p2p/toDictionary2"><span>系统数据字典目录</span></a></li>
							<li class="systemDictionaryItem"><a
								href="../p2p/toDictionaryItem"><span>系统数据字典明细</span></a>
							</li>
							<li class="ipLog"><a href="../p2p/toIpLog"><span>登录历史</span></a>
							</li>
						</ul></li>
					<li class="list-group-item"><a href="#" data-toggle="collapse"
						data-target="#auditmanage_detail"> <span>审核项目</span>
					</a>
						<ul class="in" id="auditmanage_detail">
							<li class="realAuth"><a href="./realAuth.do">实名认证审核</a></li>
							<li class="vedioAuth"><a href="./vedioAuth.do">视频认证审核</a></li>
							<li class="userFileAuth"><a href="./userFileAuth.do">认证材料审核</a>
							</li>
							<li class="bidrequest_publishaudit_list"><a
								href="./bidrequest_publishaudit_list.do">发标前审核</a></li>
							<li class="bidrequest_audit1_list"><a
								href="./bidrequest_audit1_list.do">满标一审</a></li>
							<li class="bidrequest_audit2_list"><a
								href="./bidrequest_audit2_list.do">满标二审</a></li>
							<li class="rechargeOffline"><a href="./rechargeOffline.do">线下充值审核</a>
							</li>
							<li class="moneyWithdraw"><a href="./moneyWithdraw.do">提现审核</a>
							</li>
						</ul></li>
					<li class="list-group-item"><a href="#" data-toggle="collapse"
						data-target="#systemmanage_detail"> <span>平台管理</span>
					</a>
						<ul class="in" id="systemmanage_detail">
							<li class="companyBank"><a href="./companyBank_list.do">平台账号管理</a>
							</li>
							<li><a href="./real_auth_list.do">系统账户流水</a></li>
						</ul></li>
				</ul>

				<script type="text/javascript">
				$(".in li.systemDictionaryItem").addClass("active");
				</script>
			</div>
			<div class="col-sm-9">
					<div class="page-header">
						<h3>数据字典明细</h3>
					</div>
					<form id="myform" action="../p2p/selectDictionaryItem" method="post">
						名称
						<input type="text" name="title" value="${title}" />
						<select name="dic">
							<option value="-1" <c:if test="${dic==-1}">
										selected="selected"
									</c:if>>选择字典目录</option>
							<c:forEach items="${dictionary}" var="d">
								<option value="${d.dictionaryId}" 
									<c:if test="${dic==d.dictionaryId}">
										selected="selected"
									</c:if>>${d.title}
									</option>
							</c:forEach>
						</select>
						<button class="btn btn-success" type="submit">查询名称字段</button>
						<button id="btn_add" type="button" class="btn btn-primary">增加数据字典明细</button>
					</form>
					<table class="table">
						<thead>
							<tr>
								<th>#id</th>
								<th>数据值</th>
								<th>类别</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${list}" var="l">
								<tr>
									<th>${l.itemId }</th>
									<th><c:out value="${l.itemTitle }" /></th>
									<th><c:out value="${l.parent.title }" /></th>
									<th><a href="javaScript:Delete(${l.itemId })">删除</a>&nbsp;&nbsp;&nbsp;<a>修改</a></th>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					<div>
						<c:out value="${page.currPage}" />
						/
						<c:out value="${page.totalPages}" />
					</div>
					<div id="page" class="btn-group  btn-group-sm">
						<button class="btn btn-default" type="button" onclick="toPage(1)">首页</button>
						<button id="prev" class="btn btn-default" type="button"
							onclick="toPage(${page.currPage-1 })">上一页</button>
						<button id="next" class="btn btn-default" type="button"
							onclick="toPage(${page.currPage+1 })">下一页</button>
						<button class="btn btn-default" type="button"
							onclick="toPage(${page.totalPages})">尾页</button>
					</div>
				</div>
		</div>
	</div>
	<!-- ########## -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="display: none;">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="myModalLabel">新增</h4>
                </div>
				<form id="myForm2" action="" method="Post">
					<div class="modal-body">
						<div class="form-group">
							<label for="txt_departmentname">数据值</label> 
							<input type="text" class="form-control"
								name="title" id="txt_departmentname" placeholder="名称">
						</div>
						<div class="form-group">
							<label for="txt_departmentname">所属类别</label> 
							<select name="dic2">
								<option value="-1">选择字典目录</option>
								<c:forEach items="${dictionary}" var="d">
									<option value="${d.dictionaryId}">${d.title}</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">
							<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭
						</button>
						<button type="button" id="btn_submit" class="btn btn-primary"
							data-dismiss="modal">
							<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存
						</button>
					</div>
				</form>

			</div>
        </div>
    </div>
    <!-- ########## -->
</body>

</html>